<?php
class vendaLoader extends PluginLoader{
    public function setCommonVars(){}
    public function setAdminVars(){}
    
    public function beforeCommonLoad($vars){

        $this->LoadModel('usuario/login', 'lobj');
        $this->LoadModel('usuario/perfil', 'perf');
        if(!$this->lobj->IsLoged()){
            if(CURRENT_CONTROLLER != "evento")
                Redirect('venda/evento');
        }
        elseif(LINK == 'venda/index' && !$this->perf->hasPermissionByName("Venda_DD")){
            
            if($this->perf->hasPermissionByName("Venda_REG")){
                $this->LoadModel('venda/equipe', 'eq');
                $cod = $this->eq->getCodEquipeOfUser();
                if($cod != "") Redirect('venda/equipe/show/'.$cod);
            }
            
            if($this->perf->hasPermissionByName("Venda_TELEMKT")){
                Redirect('venda/visitacomp/tele');
            }
            
            Redirect ('venda/evento');
        }
        
        $this->LoadModel('venda/visita', 'vis');
        $str = $this->vis->VisitasEmAberto();
        if($str != "") $this->setVar('popup', $str);
    }
   
}
?>